package com.shop.dingdongshoppingapi.config;

import io.swagger.annotations.Api;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


@Configuration
@EnableSwagger2 //Swagger启用配置
public class SwaggerConfig {
	//创建接口文档信息
	public ApiInfo createApiInfo(){
		return new ApiInfoBuilder().title("叮咚买菜-接口文档").description("这是一款可以帮助你节省许多时间的买菜软件").
				contact(new Contact("第四组","http://www.FanSiHua.com","987314553@qq.com")).
				version("V1.0.0").build();
	}
	@Bean //IOC容器  <bean>
	public Docket createApi(){
		return new Docket(DocumentationType.SWAGGER_2).apiInfo(createApiInfo()).select()
				.apis(RequestHandlerSelectors.withClassAnnotation(Api.class)).build();
	}
}
